import { call, put, takeEvery } from 'redux-saga/effects'
function* watchSaga1 () {
  // while (true) {
  //   // take监听，组件发来的action
  //   yield take("get-list1")
  //   // fork 同步执行异步处理函数
  //   yield fork(getList1)
  // }
  yield takeEvery("get-list1", getList1)
}
function* getList1 () {
  // 异步处理
  // call函数发出异步请求call(返回值是promise对象函数)
  let res = yield call(getListAction1)
  // put函数发出新的action
  yield put({
    type: "change-list1",
    playload: res
  })
}
// promise对象函数
function getListAction1 () {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve(["1111", "2222", "3333", "4444", "5555", "6666"])
    }, 2000)
  })
}
export default watchSaga1
export { getList1 }